import request from '../utils/request.js'

export const minegoods = (i)=>{ //我的界面商品数据包
    return request.get(`/yd/mall/productSales?pageIndex=${i}&pageSize=10&typeId=RECOMMEN_FOR_YOU`)
}

export const gethomeword = ()=>{ //首页热搜词
    return request.get(`/yd/supplier/activity/popular?type=1`)
}

export const getallbanner = ()=>{ //全部轮播图
    return request.get(`/yd/supplier/h5/index/banner/list?typeIds=ROTATION_BANNER&typeIds=KING_KONG_ICON&typeIds=YDW_NEWS&typeIds=INDEX_BANNER_LEFT&typeIds=INDEX_BANNER_RIGHT&typeIds=INDEX_BANNER_R_UP&typeIds=INDEX_BANNER_R_DOWN&typeIds=INDEX_BANNER_L_DOWN&typeIds=INDEX_BANNER_L_FOOTER_ONE&typeIds=INDEX_BANNER_L_FOOTER_TWO&typeIds=INDEX_BANNER_L_FOOTER_THREE&typeIds=INDEX_BANNER_L_FOOTER_FOURTH`)
}

export const getlooklist = ()=>{ //看一看列表
    return request.get(`/yd/supplier/indexProduct/findStrictElection?channelCode=YAODOU`)
}

export const getgrouplist = ()=>{ //好物拼团列表
    return request.get(`/yd/supplier/mallGroupPurchasePromotion/findH5MgppList?index=1&page=9&partyId=ALL`)
}

export const gethomegoodslist = ()=>{ //首页商品列表
    return request.get(`/yd/supplier/indexProduct/findIndexProductList?channelCode=YAODOU`)
}
export const getydgjlist = ()=>{ //药兜国际商品列表
    return request.get(`/yd/es/esSearch?pageIndex=1&pageSize=20&foreignTrade=Y`)
}
export const detailproductinfo = (id)=>{ //详情页商品数据
    return request.get(`/yd/product/info?productId=${id}`)
}
export const detailfreight = (id)=>{ //详情页商品数据
    return request.get(`/yd/product/merchantFreight/findFreightTemplate?productId=${id}`)
}
export const detailrecommend = (id)=>{ //详情页推荐商品列表
    return request.get(`/yd/product/sameProduct?categoryId=10052&productId=${id}&partyId=DP0035&channelCode=YAODOU`)
}
export const detaildetail = (id)=>{ //详情页图文详情
    return request.get(`/yd/product/selectContact?productId=${id}`)
}
export const detailcomment = (id)=>{ //详情页评论列表
    return request.post(`/yd/product/questions/getQuestionsList`,{
        "productId": id,
        "pageNum": 1,
        "pageSize": 2
    })
}
export const detailaddcart = (o)=>{ //详情页加入购物车
    return request.post(`/yd/shopping/cart/add`,o)
}

export const getaddresslist = ()=>{ //地址列表
    return request.get(`/yd/user/contact/list?index=1&page=20`)
}
export const getcitys = (cityid)=>{ //多级联动信息
    return request.get(`/yd/user/contact/findProvCode?provCode=${cityid}`)
}
export const addaddress = (o)=>{ //添加地址
    return request.post(`/yd/user/contact/save`,o)
}
export const editaddress = (o)=>{ //修改地址
    return request.post(`/yd/user/contact/edit`,o)
}
export const deleteaddress = (id)=>{ //删除地址
    return request.get(`/yd/user/contact/dele?id=${id}`)
}

export const orderinfo = ()=>{ //详情页结算
    return request.get(`/yd/shopping/cart/confirm/order?isNormal=false`)
}
export const cartvalidate = ()=>{ //购物车提交到结算页
    return request.get(`/yd/shopping/cart/confirm/validate`)
}

export const cartorderinfo = ()=>{ //购物车结算
    return request.get(`/yd/shopping/cart/confirm/order?isNormal=true`)
}

export const editdefaultaddress = (o)=>{ //修改默认地址
    return request.post(`/yd/shopping/cart/selectDefault`,o)
}



export const register = (obj)=>{ //注册
    return request.post(`/node/users`,obj)
}
export const login = ({name,password})=>{ //登录
    return request.get(`/node/users?name=${name}&password=${password}`)
}
export const gettuser = (name)=>{ //获取请求头
    return request.get(`/node/gettuser?name=${name}`)
}

export const imgUpload = (formData)=>{
    return request.post('/node/users/upload', formData, { //请求后端图片上传接口
        headers: {
            'enctype': 'multipart/form-data'  //跟后端约定数据包格式
        }
    })
}

export const userUpdate = (userid,newInfo)=>{ //更新用户信息
    return request.put('/node/users',{userid,newInfo})
}

export const deleteuser = (id)=>{ //注销账号
    return request.get(`/node/users/del?id=${id}`)
}